package com.cskaoyan.service.wx;

import com.cskaoyan.bean.User;
import com.cskaoyan.bean.UserExample;
import com.cskaoyan.bean.vo.LoginInfo;
import com.cskaoyan.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 杨杰
 * @version V1.0
 * @Package com.cskaoyan.service
 * @date 2020/12/8 11:12
 * @Copyright © 暂时还没有
 */
@Service
public class WxAuthServiceImp implements WxAuthService{

    @Autowired
    UserMapper userMapper;
    @Override
    public LoginInfo login(User user) {

        LoginInfo userInfo = userMapper.selectByUsername(user);

        return userInfo;
    }

    @Override
    public int selectById(String username) {
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria=userExample.createCriteria();
        if (username != null) {
            criteria.andUsernameEqualTo(username);
        }
        List<User> users = userMapper.selectByExample(userExample);
        Integer id = users.get(0).getId();
        return id;
    }
}
